<?php

/**
 * Created by PhpStorm.
 * User: ls721
 * Date: 2016/10/28 0028
 * Time: 21:18
 */
class Domain_Dispatch
{

    public function listDispatch($doctor_id, $event_id)
    {
        $model = new Model_Dispatch();
        return $model->listDispatch($doctor_id, $event_id);
    }

    public function getDispatch($dispatch_id)
    {
        $model = new Model_Dispatch();
        $rs1 = $model->getDispatch($dispatch_id);
        $model_Event = new Model_Event();
        $rs2 = $model_Event->getEventInfo($rs1["EventId"]);
        return array_merge($rs2, $rs1);

    }

    public function listDoctorOfDispatch($event_id, $lng, $lat)
    {
        $rs = "ss";

        $model = new Model_Dispatch();
        $rs = $model->listDoctorOfDispatch($event_id);
//        if (count($rs) == 0) {
//            return '';
//        }
        $domain = new Domain_Doctor();
        // array_splice($rs,1,1);
        $i = 0;

        for ($i = 0; $i < count($rs); $i++) {
            $value = $rs[$i];
            $dis = $domain->getDistance($lng, $lat, $value['Lng'], $value['Lat']);
            $value["Distance"] = $dis;
            $rs[$i] = $value;
        }
        return $rs;
    }

}